package view;

import java.awt.Image;
import java.util.HashMap;
import java.util.Map;

public class ModelToImage {
	
	/**
	 * This Map is a map between the String modelName to a String imageName
	 */
	private static final Map<String, String> images = new HashMap<String, String>();
	/**
	 * Allows one to add to static map images
	 * @param modelName The key that is the modelName
	 * @param imageName The data that is mapped to modelName, should be a directory: /src/..../images
	 */
	public static void addImage(String modelName, String imageName) {
		images.put(modelName, imageName);
	}
	/**
	 * Returns the Image with the associated modelName
	 * @param modelName the name of the image that is associated with the Image
	 * @return Image of the model
	 */
	public static Image getImage(String modelName) {
		String directory = getDirectoryLocation( modelName );
		return ImageFileToImage.getImage( directory );
	}
	
	/**
	 * Returns the directory name  based on the modelName
	 * @param modelName the modelName to pass
	 * @return the string of the directory
	 */
	private static String getDirectoryLocation( String modelName ) {
		String name = images.get( modelName );
		return (name == null ) ? "" : name; 
	}
}
